/* eslint-disable @typescript-eslint/no-var-requires */
const inquirer = require('inquirer')
const { cmd } = require('./common')

async function run() {
  console.log('正在同步远程仓库代码...')
  await cmd('git pull')
  await cmd('git add .')
  const answer = await inquirer.prompt({
    type: 'list',
    name: 'type',
    message: '请选择提交类型:',
    choices: [
      { name: 'fix', value: 'fix' },
      { name: 'feat', value: 'feat' }
    ]
  })
  const answer2 = await inquirer.prompt({
    type: 'input',
    name: 'info',
    message: '请输入提交信息:'
  })
  await cmd(`git commit -m "${answer.type}: ${answer2.info}`)
  await cmd('git push')
  console.log('代码已同步至远程仓库...')
}
run()
